export function autoUnit(val: any, toFixed = 2) {
  if (val && val > 10000) {
    let unit = '万';
    val = (val / 10000);
    if (val > 10000) {
      unit = '亿';
      val = (val / 10000);
    }
    if (val > 10000) {
      unit = '万亿';
      val = (val / 10000);
    }
    val = val.toFixed(toFixed) + unit;
  }
  return val;
}

export function hexToRgb(hex: string) {
  // 去除井号并分解RGB部分
  const r = parseInt(hex.slice(1, 3), 16);
  const g = parseInt(hex.slice(3, 5), 16);
  const b = parseInt(hex.slice(5, 7), 16);

  // 添加透明度，默认为1
  const a = 1; // 如果需要可调整

  // 返回RGBA格式
  return {r, g, b};
}